# Copyright (C) 2008 Paul Hummer
# 
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

__licence__ = 'GPLv2'
__copyright__ = '2008, Paul Hummer'
__author__ = 'Paul Hummer <paul@ironlionsoftware.no.spam.com>'

from backend.core.db.connection import db
from backend.core.db.query import Query
from backend.core.db import types

class NewsFeed(types.Model):

    entries = types.OneToMany('NewsEntry')

    class Meta:
        defaults = {
            'url' : '',
            'title' : '',
            'description' : '',
        }

class NewsEntry(types.Model):

    feed = types.ForeignKey(NewsFeed)

    class Meta:
        defaults = {
            'url': '',
            'title': '',
            'description': '',
            'datetime': '',
            'isread': False,
        }

class PhotoAlbum(types.Model):

    images = types.OneToMany('PhotoImage')

    class Meta:
        default = {
            'title': '',
            'description': '',
            'datetime': '',
        }

class PhotoImage(types.Model):

    album = types.ForeignKey(PhotoAlbum)

    class Meta:
        default = {
            'filename': '',
            'thumb': '',
            'title': '',
            'description': '',
            'datetime': '',
        }

class MusicAlbum(types.Model):

    tracks = types.OneToMany('MusicTrack')

    class Meta:
        default = {
            'artist': '',
            'title': '',
            'year': '',
            'genre': '',
        }

class MusicTrack(types.Model):

    album = types.ForeignKey(MusicAlbum)

    class Meta:
        default = {
            'filename': '',
            'title': '',
            'tracknumber': '',
            'rating': '',
            'length': '',
            'bitrate': '',
            'comment': '',
            'lyrics': '',
        }

class MusicPlaylist(types.Model):

    class Meta:
        default = {
            'title': '',
        }

#This model doesn't need to be here after I get the ManyToMany type figured out
class MusicPlaylistTrack(types.Model):

    track = types.ForeignKey(MusicTrack)
    playlist = types.ForeignKey(MusicPlaylist)

    class Meta:
        default = {}

class VideoFile(types.Model):

    class Meta:
        default = {
            'filename': '',
            'thumb': '',
            'type': 'CLIP',
        }

class VideoSeries(types.Model):

    class Meta:
        default = {
            'title': '',
            'actor_1': '',
            'actor_2': '',
            'actor_3': '',
            'actor_4': '',
            'actor_5': '',
            'writer_1': '',
            'writer_2': '',
            'director_1': '',
            'director_2': '',
        }

class VideoMeta(types.Model):

    file = types.ForeignKey(VideoFile)
    series = types.ForeignKey(VideoSeries)

    class Meta:
        default = {
            'season': '',
            'episode': '',
            'runtime': 0,
            'genres': '',
            'year': 0,
            'plot': '',
        }

